package com.example.controller;

import com.example.entity.Category;
import com.example.service.CategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 分类(Category)表控制层
 *
 * @author makejava
 * @since 2022-03-04 14:03:22
 */
@RestController
@RequestMapping("categories")
@Slf4j
public class CategoryController {
    /**
     * 服务对象
     */
    @Resource
    private CategoryService categoryService;


    /**
     * 根据类别id查询
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Category category(@PathVariable("id") Integer id){
        Category category = categoryService.queryById(id);
        log.info("接收到的视频类别信息{}",category);
        return category;
    }


    /**
     * 视频类型
     * @return
     */
    @GetMapping("/")
    public List<Category> categories(){
        return categoryService.findCategory();
    }

}

